import { defineStore } from "pinia"

// 员工登录状态管理
export const useEmployeeStore = defineStore('employee', () => {
    const employee_id = ref(null);      // 工号
    const employee_name = ref(null);    // 员工姓名

    function login(id, name) {
        // 保存属性
        employee_id.value = id;
        employee_name.value = name;
    }

    function logout() {
        // 清除属性
        employee_id.value = null;
        employee_name.value = null;
    }

    return {employee_id, employee_name, login, logout}
},
{
    persist: {
        storage: sessionStorage
    }
});